<div class="bjui-pageContent">
    <form id="communicationprotocol-edit" class="form-horizontal" method="post"  action='/communicationprotocol/edit'>
        <input type="hidden"  class="form-control input-nm" name="id" value="{{'data[id]'}}" >
        <div class="form-group">
            <label class="col-lg-12 col-sm-12 control-label"><span class="required-span">*</span>通信协议名称:
                 
            </label>
            <div class="col-lg-12 col-sm-12">
                <input type="text" class="form-control input-nm" value="{{'data[name]'}}" name="name">
            </div>
        </div>
        <div class="form-group">
            <label class="col-lg-12 col-sm-12 control-label"><span class="required-span">*</span>端口:
                 
            </label>
            <div class="col-lg-12 col-sm-12">
                <input type="text" class="form-control input-nm" value="{{'data[port]'}}" name="port">
            </div>
        </div>
        
        <div class="form-group">
            <label class="col-lg-12 col-sm-12 control-label">通信协议字典描述:
            </label>
            <div class="col-lg-12 col-sm-12">
                 <textarea style="width: 100%;height: 100px" name="memo">{{'data[memo]'}}</textarea>
            </div>
        </div>
       
    </form>
</div>
<div class="btns-group bjui-pageFooter">
    <button type="button" class="close-btn">取消</button>
    <button type="submit" class="save-btn">保存</button>
</div>

<script type="text/javascript">

        $(document).ready(function() {
              dialog_close(); 
            $('#communicationprotocol-edit').formValidation({            //表单
                // message: 'This value is not valid',
                trigger:'blur',
                icon: {
                    valid: 'glyphicon glyphicon-ok',           //默认指示验证结果图标为null
                    invalid: 'glyphicon glyphicon-remove',
                    validating: 'glyphicon glyphicon-refresh'
                }, 
                fields: {                                 
                    name: {                            //字段
                        validators: {                     //验证器
                            notEmpty: {
                                message: '请填写通信协议名称'
                            },
                            regexp: {
                                regexp: /^[\u4e00-\u9fa5_a-zA-Z0-9-]{2,30}$/,
                                message: '信协议名称只能由字母、数字、中文、下划线和减号组成,长度必须2到30之间'
                            }
                        }
                    },
                    port: {
                        validators: {
                            notEmpty: {
                                message: '请填写端口号'
                            },
                             between: {
                                min: 1025,
                                max: 65535,
                                message: '请填写1025至65535之间的端口'
                            }
                        }
                    },
                    memo:{
                        validators: {
                            stringLength:{
                              message:'通信协议字典描述不得超过200个字符',
                              max:200
                            }
                        }
                    } 
                }
            })
             .on('success.form.fv', function(e) {
            // Prevent form submission
            e.preventDefault();

            // Get the form instance
            var $form = $(e.target);

            // Get the FormValidation instance
            var bv = $form.data('formValidation');
            // Use Ajax to submit form data
            $.post($form.attr('action'), $form.serialize(), function(result) {
                if(result.statusCode=='200'){
                    BJUI.alertmsg('ok',result.message);
                    BJUI.dialog('closeCurrent');
                    BJUI.navtab('refresh', 'syscommunicationprotocol');
                }else{
                  BJUI.alertmsg('error',result.message);
                }
            }, 'json');
        });
        });
    </script>